# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

_realname=dnspython
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
provides=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
replaces=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=2.4.2
pkgrel=1
pkgdesc="A DNS toolkit for Python (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
url='https://www.dnspython.org/'
license=('spdx:ISC')
depends=(
  "${MINGW_PACKAGE_PREFIX}-python"
)
optdepends=(
  "${MINGW_PACKAGE_PREFIX}-python-cryptography: DNSSEC support"
  "${MINGW_PACKAGE_PREFIX}-python-requests-toolbelt: DoH support"
  "${MINGW_PACKAGE_PREFIX}-python-idna: support for updated IDNA 2008"
  #"${MINGW_PACKAGE_PREFIX}-python-curio: async support"
  #"${MINGW_PACKAGE_PREFIX}-python-trio: async support"
  #"${MINGW_PACKAGE_PREFIX}-python-sniffio: async support"
)
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-python-build"
  "${MINGW_PACKAGE_PREFIX}-python-installer"
  "${MINGW_PACKAGE_PREFIX}-python-poetry-core"
)
checkdepends=(
  "${MINGW_PACKAGE_PREFIX}-python-idna"
  "${MINGW_PACKAGE_PREFIX}-python-cryptography"
  #"${MINGW_PACKAGE_PREFIX}-python-trio"
  "${MINGW_PACKAGE_PREFIX}-python-pytest"
)
source=(https://files.pythonhosted.org/packages/source/${_realname::1}/$_realname/$_realname-$pkgver.tar.gz)
sha256sums=('8dcfae8c7460a2f84b4072e26f1c9f4101ca20c071649cb7c34e8b6a93d58984')

build() {
  cd "${srcdir}"
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"

  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
    cd "${_realname}-${pkgver}"

    pytest
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"

  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
